<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery-3.6.0.js"></script>
  </head>
  <body>
    <ul>
      <li>data1</li>
      <li>data2</li>
      <li>data3</li>
      <li>data4</li>
      <li>data5</li>
      <li>data6</li>
    </ul>
  </body>
</html>
<script>
  //方法一：
  $.each($('li'), function (index, ele) {
    console.log('方法一索引:' + index + ',元素 dom:' + ele.innerHTML)
    console.log('方法一索引:' + index + ',元素 jq:' + $(ele).text())
  })

  //方法二
  $('li').each(function (index, ele) {
    console.log('方法二索引:' + index + ',元素 dom:' + ele.innerHTML)
    console.log('方法二索引:' + index + ',元素 jq:' + $(ele).text())
  })

  //传统的方式
  var $li = $('li')
  for (var i = 0; i < $li.length; i++) {
    console.log('======dom=======' + $li[i].innerText)
    console.log('=======jq======' + $($li[i]).html())
  }
</script>
